<template>
	<view class="h1">
		<!-- 头部 -->
		我的信息
	</view>
	<view class="word">
		<!-- 个人信息卡片 -->
		<view class="info-card">
			<view class="info-content">
				<view class="name">{{name}}</view>
				<view class="email">{{email}}</view>
				<view class="password">{{password}}</view>
			</view>
			<view class="edit-btn" @tap="showEditPopup">
				<text class="edit-icon">✎</text>
				编辑资料
			</view>
		</view>

		<!-- 添加星座和年龄显示区域 -->
		<view class="info-card" style="margin-top: 20px;">
			<view class="info-row">
				<view class="info-item">
					<view class="info-content-row">
						<text>您的星座是：</text>
						<text class="info-value">{{selectedZodiac}}</text>
					</view>
					<view class="select-btn" @tap="showZodiacPopup">点击选择星座</view>
				</view>
			</view>
			<view class="info-row">
				<view class="info-item">
					<view class="info-content-row">
						<text>您的年龄是：</text>
						<text class="info-value">{{selectedAge}}</text>
					</view>
					<view class="select-btn" @tap="showAgePopup">点击选择年龄</view>
				</view>
			</view>
		</view>
	</view>

	<!-- 添加编辑信息的弹窗 -->
	<uni-popup ref="editPopup" type="center">
		<view class="popup-content-center">
			<view class="popup-header">
				<text class="popup-title">编辑个人信息</text>
				<text @tap="closeEditPopup" class="close-btn">×</text>
			</view>
			<view class="edit-form">
				<view class="form-item">
					<text class="label">用户名：</text>
					<input type="text" v-model="tempInfo.name" placeholder="请输入用户名" class="input"/>
				</view>
				<view class="form-item">
					<text class="label">邮箱：</text>
					<input type="text" v-model="tempInfo.email" placeholder="请输入邮箱" class="input"/>
				</view>
				<view class="form-item">
					<text class="label">密码：</text>
					<input type="password" v-model="tempInfo.password" placeholder="请输入密码" class="input"/>
				</view>
			</view>
			<view class="popup-footer">
				<text @tap="closeEditPopup" class="cancel-btn">取消</text>
				<text @tap="confirmEdit" class="confirm-btn">确定</text>
			</view>
		</view>
	</uni-popup>

	<!-- 星座选择弹窗 -->
	<uni-popup ref="zodiacPopup" type="center">
		<view class="popup-content-center">
			<view class="popup-header">
				<text class="popup-title">选择星座</text>
				<text @tap="closeZodiacPopup" class="close-btn">×</text>
			</view>
			<scroll-view scroll-y class="zodiac-list">
				<view 
					class="zodiac-item" 
					v-for="(item, index) in zodiacList" 
					:key="index"
					:class="{'selected': tempZodiac === item}"
					@tap="selectZodiac(item)"
				>
					{{item}}
				</view>
			</scroll-view>
			<view class="popup-footer">
				<text @tap="closeZodiacPopup" class="cancel-btn">取消</text>
				<text @tap="confirmZodiac" class="confirm-btn">确定</text>
			</view>
		</view>
	</uni-popup>
	
	<!-- 年龄选择弹窗 -->
	<uni-popup ref="popup" type="center">
		<view class="popup-content-center">
			<view class="popup-header">
				<text class="popup-title">选择年龄</text>
				<text @tap="closePopup" class="close-btn">×</text>
			</view>
			<view class="picker-container">
				<picker-view 
					:indicator-style="indicatorStyle" 
					:value="ageIndex" 
					@change="onAgeChange" 
					class="picker-view"
				>
					<picker-view-column>
						<view class="item" v-for="(age, index) in ageRange" :key="index">
							{{age}}岁
						</view>
					</picker-view-column>
				</picker-view>
			</view>
			<view class="popup-footer">
				<text @tap="closePopup" class="cancel-btn">取消</text>
				<text @tap="confirmAge" class="confirm-btn">确定</text>
			</view>
		</view>
	</uni-popup>
</template>

<script setup>
import { ref } from 'vue'
// 用户信息数据
const name = ref('用户名')
const email = ref('example@email.com')
const password = ref('********')

// 星座选择相关
const zodiacPopup = ref(null)
const selectedZodiac = ref('请选择')
const tempZodiac = ref('')
const zodiacList = [
	'白羊座', '金牛座', '双子座', 
	'巨蟹座', '狮子座', '处女座',
	'天秤座', '天蝎座', '射手座', 
	'摩羯座', '水瓶座', '双鱼座'
]

// 显示星座选择弹窗
const showZodiacPopup = () => {
	tempZodiac.value = selectedZodiac.value // 初始化临时选择为当前选择
	zodiacPopup.value.open()
}

// 关闭星座选择弹窗
const closeZodiacPopup = () => {
	zodiacPopup.value.close()
}

// 选择星座
const selectZodiac = (zodiac) => {
	tempZodiac.value = zodiac
}

// 确认星座选择
const confirmZodiac = () => {
	if (tempZodiac.value && tempZodiac.value !== '请选择') {
		selectedZodiac.value = tempZodiac.value
		closeZodiacPopup()
		
		// 显示选择成功提示
		uni.showToast({
			title: `已选择${tempZodiac.value}`,
			icon: 'none',
			duration: 1500
		})
	}
}

// 年龄选择相关
const popup = ref(null)
const selectedAge = ref('请选择')
const ageIndex = ref([0])
const ageRange = Array.from({length: 100}, (_, i) => i + 1)
const indicatorStyle = 'height: 40px;'

// 显示年龄选择弹窗
const showAgePopup = () => {
	popup.value.open()
}

// 关闭弹窗
const closePopup = () => {
	popup.value.close()
}

// 年龄改变事件
const onAgeChange = (e) => {
	ageIndex.value = e.detail.value
}

// 确认年龄选择
const confirmAge = () => {
	selectedAge.value = ageRange[ageIndex.value[0]] + '岁'
	closePopup()
	
	// 显示选择成功提示
	uni.showToast({
		title: `已选择${ageRange[ageIndex.value[0]]}岁`,
		icon: 'none',
		duration: 1500
	})
}

// 添加悬浮效果状态
const isHovered = ref(false)

// 触摸开始
const startHover = () => {
	isHovered.value = true
}

// 触摸结束
const endHover = () => {
	isHovered.value = false
}

// 在现的代码基础上添加以下内容
const editPopup = ref(null)
const tempInfo = ref({
	name: '',
	email: '',
	password: ''
})

// 显示编辑弹窗
const showEditPopup = () => {
	// 初始化临时数据
	tempInfo.value = {
		name: name.value,
		email: email.value,
		password: password.value
	}
	editPopup.value.open()
}

// 关闭编辑弹窗
const closeEditPopup = () => {
	editPopup.value.close()
}

// 确认编辑
const confirmEdit = () => {
	// 更新信息
	name.value = tempInfo.value.name
	email.value = tempInfo.value.email
	password.value = tempInfo.value.password
	
	closeEditPopup()
	
	// 显示成功提示
	uni.showToast({
		title: '修改成功',
		icon: 'success',
		duration: 1500
	})
}
</script>

<style>
/* 基础样式 */
.h1 {
	font-size: 20px;
	font-weight: bold;
	text-align: center;
	padding: 20px;
	background-color: #f8f8f8;
}

.word {
	padding: 20px;
}

.word view {
	padding: 15px;
	margin-bottom: 10px;
	background-color: #ffffff;
	border-radius: 8px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.a {
	padding: 25px;
	background: linear-gradient(145deg, #ffffff, #f0f0f0);
	border-radius: 20px;
	margin: 20px;
	box-shadow: 10px 10px 20px #d9d9d9,
				-10px -10px 20px #ffffff;
	transition: all 0.3s ease;
	position: relative;
	overflow: hidden;
}

/* 悬浮效果 */
.a.hover {
	transform: scale(0.98);
	box-shadow: 5px 5px 10px #d9d9d9,
				-5px -5px 10px #ffffff;
}

/* 添加背景动画 */
.a::before {
	content: '';
	position: absolute;
	top: -50%;
	left: -50%;
	width: 200%;
	height: 200%;
	background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
	transform: rotate(0deg);
	animation: rotate 10s linear infinite;
	pointer-events: none;
}

/* 卡片项样式 */
.card-item {
	transition: all 0.3s ease;
	position: relative;
	overflow: hidden;
	border: 1px solid rgba(255, 255, 255, 0.1);
	backdrop-filter: blur(5px);
}

/* 卡片悬浮效果 */
.card-hover {
	transform: translateY(-2px);
	box-shadow: 0 5px 15px rgba(0, 114, 255, 0.2);
}

/* 点击波纹效果 */
.card-item::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 5px;
	height: 5px;
	background: rgba(255, 255, 255, 0.5);
	opacity: 0;
	border-radius: 100%;
	transform: scale(1, 1) translate(-50%);
	transform-origin: 50% 50%;
}

.card-item:active::after {
	animation: ripple 1s ease-out;
}

/* 动画关键帧 */
@keyframes rotate {
	from {
		transform: rotate(0deg);
	}
	to {
		transform: rotate(360deg);
	}
}

@keyframes ripple {
	0% {
		transform: scale(0, 0);
		opacity: 0.5;
	}
	100% {
		transform: scale(100, 100);
		opacity: 0;
	}
}

/* 修改内部卡片样式 */
.text, .textt {
	background: linear-gradient(135deg, #0072ff, #00c6ff);
	padding: 15px 20px;
	border-radius: 12px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	color: white;
	margin-bottom: 15px;
	box-shadow: 0 4px 15px rgba(0, 114, 255, 0.2);
	transition: all 0.3s ease;
}

.xingzuo {
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(5px);
	border: 1px solid rgba(255, 255, 255, 0.2);
	transition: all 0.3s ease;
}

.xingzuo:active {
	transform: scale(0.95);
	background: rgba(255, 255, 255, 0.25);
}

.text {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background-color: #007AFF;
	color: white;
	padding: 15px 20px;
	border-radius: 8px;
	margin-bottom: 15px;
}

.left-content {
	display: flex;
	align-items: center;
	gap: 10px;
}

.xz, .xzz {
	font-weight: bold;
	color: white;
}

.xingzuo {
	font-size: 14px;
	padding: 5px 10px;
	background-color: rgba(255, 255, 255, 0.2);
	border-radius: 4px;
}

/* 通用弹窗样式 */
.popup-content {
	background-color: #fff;
	padding-bottom: 20px;
	border-radius: 12px 12px 0 0;
}

.popup-header {
	padding: 15px;
	text-align: center;
	position: relative;
	border-bottom: 1px solid #eee;
}

.cancel-btn, .confirm-btn {
	flex: 1;
	text-align: center;
	padding: 12px 0;
	font-size: 16px;
}

/* 年龄选择器样式 */
.picker-container {
	padding: 15px 0;
}

.picker-view {
	width: 280px;
	height: 200px;
}

.item {
	line-height: 40px;
	text-align: center;
	font-size: 16px;
}

/* 修改弹窗样式，确保两个弹窗样式统一 */
.popup-content-center {
	background-color: #fff;
	width: 280px;
	border-radius: 12px;
	overflow: hidden;
}

.popup-header {
	padding: 15px;
	text-align: center;
	position: relative;
	border-bottom: 1px solid #eee;
}

.popup-footer {
	display: flex;
	border-top: 1px solid #eee;
}

.popup-title {
	font-size: 16px;
	font-weight: bold;
}

.close-btn {
	position: absolute;
	right: 15px;
	top: 50%;
	transform: translateY(-50%);
	font-size: 24px;
	color: #999;
	padding: 5px;
}

.cancel-btn, .confirm-btn {
	flex: 1;
	text-align: center;
	padding: 12px 0;
	font-size: 16px;
}

.cancel-btn {
	border-right: 1px solid #eee;
	color: #666;
}

.confirm-btn {
	color: #007AFF;
}

/* 星座选择样式 */
.zodiac-list {
	max-height: 300px;
	padding: 15px;
}

.zodiac-item {
	height: 50px;
	line-height: 50px;
	text-align: center;
	background-color: #f5f5f5;
	margin-bottom: 10px;
	border-radius: 8px;
}

.zodiac-item.selected {
	background-color: #007AFF;
	color: white;
}

.textt {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background-color: #007AFF;
	color: white;
	padding: 15px 20px;
	border-radius: 8px;
	margin-bottom: 15px;
}

.left-contenttt {
	display: flex;
	align-items: center;
	gap: 10px;
}

.dll {
	font-weight: bold;
	color: white;
}

.info-card {
	position: relative;
	padding: 20px;
	background: linear-gradient(145deg, #ffffff, #f0f0f0);
	border-radius: 15px;
	box-shadow: 5px 5px 10px #d9d9d9,
				-5px -5px 10px #ffffff;
}

.info-content {
	margin-bottom: 15px;
}

.edit-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 8px 15px;
	background: linear-gradient(135deg, #0072ff, #00c6ff);
	color: white;
	border-radius: 20px;
	font-size: 14px;
	cursor: pointer;
	transition: all 0.3s ease;
}

.edit-btn:active {
	transform: scale(0.95);
}

.edit-icon {
	margin-right: 5px;
	font-size: 16px;
}

.edit-form {
	padding: 15px;
}

.form-item {
	margin-bottom: 15px;
}

.label {
	display: block;
	margin-bottom: 5px;
	font-size: 14px;
	color: #666;
}

.input {
	width: 100%;
	height: 40px;
	padding: 0 10px;
	border: 1px solid #eee;
	border-radius: 8px;
	font-size: 14px;
	background-color: #f8f8f8;
}

.input:focus {
	border-color: #007AFF;
	background-color: #fff;
}

/* 修改现有的样式 */
.name, .email, .password {
	padding: 10px 15px;
	margin-bottom: 10px;
	background-color: #ffffff;
	border-radius: 8px;
	box-shadow: inset 2px 2px 5px #d9d9d9,
				inset -2px -2px 5px #ffffff;
	transition: all 0.3s ease;
}

/* 在现有样式的基础上添加 */
.info-row {
	margin-bottom: 15px;
}

.info-row:last-child {
	margin-bottom: 0;
}

.info-row {
	margin-bottom: 15px;
}

.info-row:last-child {
	margin-bottom: 0;
}

/* 添加新的统一样式 */
.info-item {
	background: #FFE4E1;
	padding: 15px 20px;
	border-radius: 12px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	color: #4169E1;
	box-shadow: 0 4px 15px rgba(255, 182, 193, 0.2);
	transition: all 0.3s ease;
	border: 1px solid #FFB6C1;
}

.info-content-row {
	display: flex;
	align-items: center;
	gap: 10px;
}

.info-content-row text {
	color: #4169E1;
}

.info-value {
	font-weight: bold;
	color: #4169E1;
}

.action-btn {
	font-size: 14px;
	padding: 5px 10px;
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(5px);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 4px;
	transition: all 0.3s ease;
}

.action-btn:active {
	transform: scale(0.95);
	background: rgba(255, 255, 255, 0.25);
}

.text {
	background: linear-gradient(135deg, #0072ff, #00c6ff);
	padding: 15px 20px;
	border-radius: 12px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	color: white;
	margin-bottom: 15px;
	box-shadow: 0 4px 15px rgba(0, 114, 255, 0.2);
	transition: all 0.3s ease;
}

.left-content {
	display: flex;
	align-items: center;
	gap: 10px;
}

.value-text {
	font-weight: bold;
	color: white;
}

.xingzuo {
	font-size: 14px;
	padding: 5px 10px;
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(5px);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 4px;
	transition: all 0.3s ease;
}

.xingzuo:active {
	transform: scale(0.95);
	background: rgba(255, 255, 255, 0.25);
}

.info-row {
	margin-bottom: 15px;
}

.info-row:last-child {
	margin-bottom: 0;
}

.info-item {
	background: #FFE4E1;
	padding: 15px 20px;
	border-radius: 12px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	color: #4169E1;
	box-shadow: 0 4px 15px rgba(255, 182, 193, 0.2);
	transition: all 0.3s ease;
	border: 1px solid #FFB6C1;
}

.info-content-row {
	display: flex;
	align-items: center;
	gap: 10px;
}

.info-content-row text {
	color: #4169E1;
}

.info-value {
	font-weight: bold;
	color: #4169E1;
}

.select-btn {
	font-size: 14px;
	padding: 5px 10px;
	background: pink;
	color: blue;
	border-radius: 4px;
	transition: all 0.3s ease;
	border: none;
}

.select-btn:active {
	transform: scale(0.95);
	background: pink;
}
</style>
